<?php

namespace App\Http\Requests\V1;
use Log;

class PasswordUpdateRequest extends BaseRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return parent::authorize();
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $rules = parent::rules();
        $rules['code'] = 'bail|required|exists:admin_users,code,deleted_at,NULL';
        $rules['password'] = 'bail|required';
        $rules['newpwd'] = 'bail|required|min:6|alpha_dash';
        return $rules;
    }

    /**
     * Get custom messages for validator errors.
     *
     * @return array
     */
    public function messages()
    {
        $message = parent::messages();
        $message['code.required'] = '登录账号不能为空';
        $message['code.exists'] = '登录账号不存在';
        $message['password.required'] = '登录密码不能为空';
        $message['newpwd.required'] = '新密码不能为空';
        $message['newpwd.min'] = '新密码不少于6个字符';
        $message['newpwd.alpha_dash'] = '新密码必须由数字及字母组成';
        return $message;
    }
}
